//
//  AddSaleActivityViewController.m
//  qianke
//
//  Created by ZX on 2017/6/29.
//  Copyright © 2017年 ZX. All rights reserved.
//

#import "AddSaleActivityViewController.h"
#import "ZXDatePickerController.h"
#import "ZXChoseController.h"
#import "ZXPickerView.h"
#import "AADatePicker.h"
@interface AddSaleActivityViewController ()<UITextViewDelegate,UITableViewDataSource,UITableViewDelegate,myPickerViewDelegate,AADatePickerDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *myScrollView;
@property (strong, nonatomic) UITextView *shadowContentTextView;
@property (weak, nonatomic) IBOutlet UIButton *sureBtn;
@property (weak, nonatomic) UITextView *remarksTextView;
@property (weak, nonatomic) IBOutlet UIView *customView;
- (IBAction)resetBtn_click:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *huodongleixingBtn;
@property (weak, nonatomic) IBOutlet UIButton *resultBtn;
@property (weak, nonatomic) IBOutlet UIButton *isReturnBtn;
@property (weak, nonatomic) IBOutlet UITextField *isReturnFlied;
@property (weak, nonatomic) IBOutlet UITextView *customNumFlied;
@property (weak, nonatomic) IBOutlet UIView *textBgView2;
@property (weak, nonatomic) IBOutlet UIView *textBgView3;
@property (weak, nonatomic) IBOutlet UIButton *isOrderBtn;
@property (weak, nonatomic) IBOutlet UIView *textBgView;
@property (weak, nonatomic) IBOutlet UITextField *isOrderedFlied;
@property(assign,nonatomic)NSInteger y;
@property(copy,nonatomic)NSMutableDictionary * infoDic;
/*choseTableView*/
@property(strong ,nonatomic)UITableView*choseTableView;
/*arr*/
@property(copy ,nonatomic)NSMutableArray*choseArr;

@property (nonatomic ,strong) ZXPickerView * zxpickerView1;
@property (nonatomic ,strong) ZXPickerView * zxpickerView2;
@property (nonatomic ,strong) ZXPickerView * zxpickerView3;
@property (nonatomic ,strong) ZXPickerView * zxpickerView4;
@property (nonatomic, strong) UIView *maskLayer;
@property(assign ,nonatomic)NSInteger type;
@property (weak, nonatomic) IBOutlet UITextField *huodongleixingTextflied;
@property (weak, nonatomic) IBOutlet UITextField *resultTexeflied;
@property (weak, nonatomic) IBOutlet UITextField *daodianshijianTextflied;
@property (weak, nonatomic) IBOutlet UITextField *genjinshijianTextFlied;

/**<>*/
@property(copy ,nonatomic)NSMutableDictionary * param;
@property(assign ,nonatomic)NSInteger lastPosition;
@property(strong ,nonatomic)AADatePicker *datePicker;


/*timetemStr*/
@property(copy ,nonatomic)NSString*timetemStr;
@property(copy ,nonatomic)NSString*timetemStr2;
@end

@implementation AddSaleActivityViewController
@synthesize choseTableView,choseArr,maskLayer;
- (void)viewDidLoad {
    [super viewDidLoad];
    AADatePicker *datePicker = [[AADatePicker alloc] initWithFrame:CGRectMake(0, ScreenHeight-204, ScreenWidth, 204) maxDate:[NSDate dateWithTimeIntervalSinceNow:365*24*60*60] minDate:[NSDate date] showValidDatesOnly:YES];
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
    view.backgroundColor = [UIColor whiteColor];
    UIButton * dateBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-75,0, 60, 44)];
    [dateBtn setTitle:@"确定" forState:UIControlStateNormal];
    [dateBtn setTitleColor:baseBlueColor forState:UIControlStateNormal];
    [view addSubview:dateBtn];
    [dateBtn addTarget:self action:@selector(dateSureBtn) forControlEvents:UIControlEventTouchUpInside];
    datePicker.hidden = YES;
    UIButton * datecancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(15,0, 60, 44)];
    [datecancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [datecancelBtn setTitleColor:baseBlueColor forState:UIControlStateNormal];
     [datecancelBtn addTarget:self action:@selector(datecancelBtn) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:datecancelBtn];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [datePicker addSubview:view];
    _datePicker = datePicker;
    datePicker.delegate = self;
    [self.view addSubview:datePicker];
    _param = [NSMutableDictionary dictionary];
    _remarksTextView.delegate = self;
    _shadowContentTextView.delegate = self;
    if (ScreenWidth <385) {
        _myScrollView.contentSize = CGSizeMake(0, 300);
    }
//    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
//        self.edgesForExtendedLayout = UIRectEdgeNone;
//    }
    if (_infoDic) {
        _infoDic = [NSMutableDictionary dictionary];
    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
    [self.view addSubview:self.zxpickerView1];
    [self.view addSubview:self.zxpickerView2];

    [self.view addSubview:self.zxpickerView3];
    [self.view addSubview:self.zxpickerView4];

    ZXTextView * beizhuTextView =[[ZXTextView alloc]initWithFrame:CGRectMake(0, 0,_textBgView.frame.size.width, _textBgView.frame.size.height)];
    beizhuTextView.delegate = self;
    _remarksTextView = beizhuTextView;
    beizhuTextView.placeHolder = @"如有建议,请在此处填写";
    [_textBgView addSubview:beizhuTextView];
    ZXTextView * beizhuTextView2 =[[ZXTextView alloc]initWithFrame:CGRectMake(0, 0,_textBgView2.frame.size.width, _textBgView2.frame.size.height)];
    beizhuTextView2.delegate = self;
    _shadowContentTextView = beizhuTextView2;
    beizhuTextView2.placeHolder = @"请输入跟进内容";
    [_textBgView2 addSubview:beizhuTextView2];
    
    ZXTextView * beizhuTextView3 =[[ZXTextView alloc]initWithFrame:CGRectMake(0, 0,_textBgView3.frame.size.width, _textBgView3.frame.size.height)];
    beizhuTextView3.delegate = self;
    _customNumFlied = beizhuTextView3;
    beizhuTextView3.placeHolder = @"请输入跟进活动";
    [_textBgView3 addSubview:beizhuTextView3];
//    self.navigationController.navigationBar.translucent = YES;
}
-(void)dateChanged:(AADatePicker *)sender
{
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    if (sender.date) {
        _timetemStr = [dateFormatter stringFromDate:sender.date];
    }
   
}
-(ZXPickerView *)zxpickerView1{
    if (!_zxpickerView1) {
        _zxpickerView1 = [[ZXPickerView alloc]initWithFrame:CGRectMake(0, ScreenHeight , ScreenWidth, ZXPickerViewHeight)];
        _zxpickerView1.delegate = self;
        NSArray * arr = [NSArray arrayWithObjects:@"来店来访",@"来电来访",@"走访调查", nil];
        [_zxpickerView1 creatPickView:arr];
    }
    return _zxpickerView1;
}
-(ZXPickerView *)zxpickerView2{
    if (!_zxpickerView2) {
        _zxpickerView2 = [[ZXPickerView alloc]initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth,ZXPickerViewHeight)];
        _zxpickerView2.delegate = self;
        NSArray * arr = [NSArray arrayWithObjects:@"成功",@"失败", nil];
        [_zxpickerView2 creatPickView:arr];
    }
    return _zxpickerView2;
}
-(ZXPickerView *)zxpickerView3{
    if (!_zxpickerView3) {
        _zxpickerView3 = [[ZXPickerView alloc]initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth,ZXPickerViewHeight)];
        _zxpickerView3.delegate = self;
        NSArray * arr = [NSArray arrayWithObjects:@"A",@"B",@"C", nil];
        [_zxpickerView3 creatPickView:arr];
    }
    return _zxpickerView3;
}
-(ZXPickerView *)zxpickerView4{
    if (!_zxpickerView4) {
        _zxpickerView4 = [[ZXPickerView alloc]initWithFrame:CGRectMake(0, ScreenHeight, ScreenWidth,ZXPickerViewHeight)];
        _zxpickerView4.delegate = self;
        NSArray * arr = [NSArray arrayWithObjects:@"确定意向",@"是否买车",@"确定购车", nil];
        [_zxpickerView4 creatPickView:arr];
    }
    return _zxpickerView4;
}
-(void)choseView{
    choseArr = [NSMutableArray arrayWithObjects:@"wode", @"wode",@"wode",@"wode",@"wode",nil];
    choseTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, ScreenHeight/2, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    choseTableView.delegate = self;
    choseTableView.dataSource = self;
    [choseTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:choseTableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSLog(@"%lu",(unsigned long)choseArr.count);
    return choseArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text = choseArr[indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    choseTableView.contentOffset = CGPointMake(0, 0);
}
-(void)viewWillLayoutSubviews{
    _myScrollView.width = ScreenWidth;
    _customView.width = ScreenWidth;
}
/**
 *  键盘将要显示
 *
 *  @param notification 通知
 */
-(void)keyboardWillShow:(NSNotification *)notification
{
    //这样就拿到了键盘的位置大小信息frame，然后根据frame进行高度处理之类的信息
    CGRect frame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
    NSLog(@"frame显示==%@",NSStringFromCGRect(frame));
    
    if (ScreenWidth <375) {
        _myScrollView.contentSize = CGSizeMake(0, 667);
        if (_shadowContentTextView.isFirstResponder) {
                _y = _shadowContentTextView.bounds.origin.y + _shadowContentTextView.frame.size.height + frame.size.height - ScreenHeight;
                    _myScrollView.contentOffset = CGPointMake(0, 354);
            }
        if (_remarksTextView.isFirstResponder) {
            _myScrollView.contentSize = CGSizeMake(0, 800);
            _y = _remarksTextView.bounds.origin.y + _remarksTextView.frame.size.height + frame.size.height-ScreenHeight;
                _myScrollView.contentOffset = CGPointMake(0, 400);
        }
        if (_customNumFlied.isFirstResponder) {
            _y = _remarksTextView.bounds.origin.y + _remarksTextView.frame.size.height + frame.size.height-ScreenHeight;
            _myScrollView.contentOffset = CGPointMake(0, 254);
        }
    }else{
        if (_remarksTextView.isFirstResponder) {
           _myScrollView.contentOffset = CGPointMake(0, 354);
        }else{
            _myScrollView.contentOffset = CGPointMake(0, 254);
        }
    }
    _myScrollView.scrollEnabled = NO;

}
/**
 *  键盘将要隐藏
 *
 *  @param notification 通知
 */
-(void)keyboardWillHidden:(NSNotification *)notification
{
    _myScrollView.scrollEnabled = YES;
    CGRect frame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
     NSLog(@"frame隐藏==%@",NSStringFromCGRect(frame));
    _myScrollView.contentOffset = CGPointMake(0,  0);
    }
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [SVProgressHUD dismiss];
    [self.view endEditing:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    int currentPostion = scrollView.contentOffset.y;
    if (currentPostion - _lastPosition > 150) {
        _lastPosition = currentPostion;
        NSLog(@"ScrollUp now");
    }
    else if (_lastPosition - currentPostion > 350)
    {
        _lastPosition = currentPostion;
//        [self.view endEditing:YES];
        
        NSLog(@"ScrollDown now");
    }
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    
    return YES;
}

- (IBAction)resetBtn_click:(id)sender {
    [_infoDic removeAllObjects];
    _customNumFlied.text = @"";
    _isReturnFlied.text = @"";
    _isOrderedFlied.text = @"";
    _resultTexeflied.text = @"";
    _huodongleixingTextflied.text = @"";
    _isReturnFlied.text = @"";
    _isOrderedFlied.text = @"";
    _customNumFlied.text = @"";
    _remarksTextView.text = @"";
    _genjinshijianTextFlied.text = @"";
    _daodianshijianTextflied.text = @"";

    _shadowContentTextView.text = @"";
    _remarksTextView.text = @"";
//    [self.view layoutIfNeeded];
}
- (IBAction)sureBtn_click:(id)sender {
    
    if (!_huodongleixingTextflied.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请选择跟进方式"];
        return;
    }
    if (!_genjinshijianTextFlied.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请选择跟进时间"];
        return;
    }
    if (!_resultTexeflied.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请选择跟进结果"];
        return;
    }
    if (!_isReturnFlied.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请选择跟进等级"];
        return;
    }
    if (!_isOrderedFlied.text.length) {
        [SVProgressHUD showErrorWithStatus:@"请选择跟进原因"];
        return;
    }
    BOOL isName = [ZXToolObj isEmpty:_customNumFlied.text];
    if (!_customNumFlied.text.length||isName) {
        [SVProgressHUD showErrorWithStatus:@"跟进活动不能为空"];
        return;
    }
    BOOL isName2 = [ZXToolObj isEmpty:_shadowContentTextView.text];

    if (!_shadowContentTextView.text.length||isName2) {
        [SVProgressHUD showErrorWithStatus:@"跟进内容不能为空"];
        return;
    }
    BOOL isName3 = [ZXToolObj isEmpty:_remarksTextView.text];

    if (!_remarksTextView.text.length||isName3) {
        [SVProgressHUD showErrorWithStatus:@"客户建议不能为空"];
        return;
    }
    
    
    if (!_customNumFlied.text.length||!_isReturnFlied.text.length||!_isOrderedFlied.text||!_resultTexeflied.text.length||!_huodongleixingTextflied.text.length||!_isReturnFlied.text.length||!_isOrderedFlied.text.length||!_customNumFlied.text.length||!_remarksTextView.text.length||!_daodianshijianTextflied||!_genjinshijianTextFlied) {
//        return;
    }
    _sureBtn.enabled = NO;
    NSString *strURL = @"http://139.196.218.206:8056/scrmForApp/followDetail";

    NSMutableDictionary * param = [NSMutableDictionary dictionary];
    [param setValue:_chanceId forKey:@"hid"];
    [param setValue:_huodongleixingTextflied.text forKey:@"type"];
    [param setValue:[_genjinshijianTextFlied.text substringToIndex:10] forKey:@"followTime"];
//    [param setValue:_genjinshijianTextFlied.text  forKey:@"createTime"];
    [param setValue:_isReturnFlied.text forKey:@"level"];
    [param setValue:_isOrderedFlied.text forKey:@"goal"];
    [param setValue:_customNumFlied.text forKey:@"hAction"];
    [param setValue:_shadowContentTextView.text forKey:@"hContent"];
    [param setValue:_resultTexeflied.text forKey:@"hResult"];
    [param setValue:_remarksTextView.text forKey:@"idea"];
    [param setValue:my_AppDelegate.dealerId forKey:@"dealerId"];
    [param setValue:@"" forKey:@"hLoad"];
    [param setValue:my_AppDelegate.dealerId forKey:@"dealerId"];

    
    NSLog(@"_param==%@",param);
    NSString *uuid = [[NSUUID UUID] UUIDString];
    NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
    NSString* phoneModel = [ZXToolObj iphoneType];
    NSLog(@"%@\n%@\n%@",uuid,phoneVersion,phoneModel);
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strURL]];
    request.HTTPMethod = @"POST";
    [request setValue:my_AppDelegate.access_token forHTTPHeaderField:accessTokenKey];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    NSData *data = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:nil];
    request.HTTPBody = data;
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if (!data||[data isEqual:[NSNull null]]) {
//            _sureBtn.enabled = YES;
//            return ;
        }
        NSDictionary * dicc = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSString * recultCode = [dicc objectForKey:@"msgCod"];
        NSString * string = [dicc objectForKey:@"message"];
        if (!recultCode||[recultCode isEqual:[NSNull null]]) {
            _sureBtn.enabled = YES;
            return;
        }else{
            
        }
        if ([recultCode isEqualToString:@"S0002"]) {
            
        }else {
            dispatch_async(dispatch_get_main_queue(), ^{
                _sureBtn.enabled = YES;
                [SVProgressHUD showErrorWithStatus:string];
            });
            return ;
        }

        if ([string isEqual:[NSNull null]]||!string) {
            _sureBtn.enabled = YES;
            return ;
        }
        if ([string containsString:@"成功"]) {
            dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showSuccessWithStatus:string];
            [self.navigationController popViewControllerAnimated:NO];
            });
        }else{
            dispatch_async(dispatch_get_main_queue(), ^{
                _sureBtn.enabled = YES;
                [SVProgressHUD showErrorWithStatus:string];
            });
            
        }
    }];

    
    
}
- (IBAction)huodongleixingBtnClick:(UIButton*)sender {
    sender.selected = !sender.selected;
    [SVProgressHUD dismiss];
    if (sender.selected) {
        [self addMaskLayer];
    }
    _type = sender.tag;
    switch (sender.tag) {
        case 200001:
            NSLog(@"客户性别");
            if (sender.selected) {
                [self.zxpickerView1 zxshow];
            }else{
                [self.zxpickerView1 zxhide];
            }
            [self.view bringSubviewToFront:_zxpickerView1];
            break;
        case 200002:
            if (sender.selected) {
                [self.zxpickerView2 zxshow];
            }else{
                [self.zxpickerView2 zxhide];
            }
            [self.view bringSubviewToFront:_zxpickerView2];
            
            NSLog(@"意向车型");
            break;
        case 200005:
            if (sender.selected) {
                [self.zxpickerView3 zxshow];
            }else{
                [self.zxpickerView3 zxhide];
            }
            [self.view bringSubviewToFront:_zxpickerView3];
            
            NSLog(@"二次到店");
            break;
        case 200006:
            if (sender.selected) {
                [self.zxpickerView4 zxshow];
            }else{
                [self.zxpickerView4 zxhide];
            }
            [self.view bringSubviewToFront:_zxpickerView4];
            
            NSLog(@"转订单");
            break;
            
            
            
            
        default:
            
            break;
    }
    
}
-(void)zxsureBtnClickReturnString:(NSString *)string{
    NSLog(@"string==%@",string);
    switch (_type) {
        case 200001:
            NSLog(@"活动类型");
            _huodongleixingTextflied.text = string;
//            if ([string isEqualToString:@"电话"]) {
//                [_param setObject:@"0" forKey:@"activity_type"];
//            }else if ([string isEqualToString:@"微信"]){
//                [_param setObject:@"1" forKey:@"activity_type"];
//            }else if ([string isEqualToString:@"到店"]){
//                [_param setObject:@"2" forKey:@"activity_type"];
//            }else if ([string isEqualToString:@"试驾"]){
//                [_param setObject:@"3" forKey:@"activity_type"];
//            }
            [self huodongleixingBtnClick:_huodongleixingBtn];
            break;
        case 200002:
            _resultTexeflied.text = string;
//            if ([string isEqualToString:@"成功"]) {
//                [_param setObject:@"1" forKey:@"track_result"];
//            }else [_param setObject:@"0" forKey:@"track_result"];
            [self huodongleixingBtnClick:_resultBtn];
            NSLog(@"意向车型");
            break;
        case 200005:
            _isReturnFlied.text = string;
//            if ([string isEqualToString:@"是"]) {
//                [_param setObject:@"1" forKey:@"is_returned"];
//            }else [_param setObject:@"0" forKey:@"is_returned"];

            [self huodongleixingBtnClick:_isReturnBtn];
            NSLog(@"二次到店");
            break;
        case 200006:
            _isOrderedFlied.text = string;
//            if ([string isEqualToString:@"是"]) {
//                [_param setObject:@"1" forKey:@"is_ordered"];
//            }else [_param setObject:@"0" forKey:@"is_ordered"];
            [self huodongleixingBtnClick:_isOrderBtn];
            NSLog(@"转订单");
            break;
        default:
            break;
    }
    [self action_removeMask];
    
}
-(void)zxcancelBtnClick{
    [self action_removeMask];
    switch (_type) {
        case 200001:
            NSLog(@"客户性别");
            [self huodongleixingBtnClick:_huodongleixingBtn];
            break;
        case 200002:
            [self huodongleixingBtnClick:_resultBtn];
            NSLog(@"意向车型");
            break;
        case 200005:
            [self huodongleixingBtnClick:_isReturnBtn];
            NSLog(@"意向车型");
            break;
        case 200006:
            [self huodongleixingBtnClick:_isOrderBtn];
            NSLog(@"意向车型");
            break;
        default:
            break;
    }
    
    NSLog(@"点击了取消按钮eee");
    
}

- (void)action_removeMask{
    // 移除全屏点击事件
    [maskLayer removeFromSuperview];
    
    
    // 移除遮罩
    //    if (maskLayer) {
    //        [maskLayer removeFromSuperlayer];
    //        [control removeFromSuperview];
    //    }
}


- (void)addMaskLayer{
    
    // 添加遮罩
    maskLayer = [UIView  new];
    [maskLayer setFrame:[[UIScreen mainScreen] bounds]];
    [maskLayer setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3]];
    [self.view addSubview:maskLayer];
}

-(void)dateSureBtn{
    [self action_removeMask];
    NSDate *date = [NSDate date];
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    
    [self.genjinshijianTextFlied setText:[dateFormatter stringFromDate:date]];
    if (_timetemStr) {
        [self.genjinshijianTextFlied setText:_timetemStr];
    }
    _timetemStr2 = self.genjinshijianTextFlied.text;
    _datePicker.hidden = YES;
}
-(void)datecancelBtn{
    [self action_removeMask];
    _datePicker.hidden = YES;
}
- (IBAction)changeBtn_click:(UIButton*)sender {
//    if (sender.selected) {
        [self addMaskLayer];
//    }
    _datePicker.hidden = NO;
    [self.view bringSubviewToFront:_datePicker];
    NSDate *date = [NSDate date];
    //实例化一个NSDateFormatter对象
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    
    [self.genjinshijianTextFlied setText:[dateFormatter stringFromDate:date]];
    if (_timetemStr2) {
        [self.genjinshijianTextFlied setText:_timetemStr2];
    }
    /*
    ZXDatePickerController * datePiakerVc = [ZXDatePickerController new];
    [self.navigationController pushViewController:datePiakerVc animated:YES];
    __weak typeof(self) weakSelf = self;
    [datePiakerVc setGetDate2:^(NSDate *date){
        NSLog(@"%@",date);
        NSString *timeSp = [NSString stringWithFormat:@"%f", [date timeIntervalSince1970]];
        NSString * time1 = [timeSp substringWithRange:NSMakeRange(0,10)];
        NSLog(@"time1:%@",[ZXToolObj getTimeF:time1]);
        weakSelf.genjinshijianTextFlied.text = [ZXToolObj getTimeF:time1];
    }];
        [datePiakerVc setGetDate:^(NSString *date){
            NSUInteger len = [date length];
            NSString *str3= @"间";
            NSString *str2= @"星期";
            NSRange range = [date rangeOfString:str2];
            NSRange range3 = [date rangeOfString:str3];
            NSString * time1 = [date substringWithRange:NSMakeRange(0, range.location)];
            NSString * time2 =  [date substringWithRange:NSMakeRange(range3.location+1,len-range3.location-4)];
            NSString * time = [time1 stringByAppendingString:time2];
            switch (sender.tag) {
                case 200003:
//                    weakSelf.genjinshijianTextFlied.text = time;
//                    [_param setObject:time forKey:@"track_date"];
//                    [_infoDic setObject:time forKey:followTimeKey];
                    break;
                case 200004:
                     weakSelf.daodianshijianTextflied.text = time;
//                    [_param setObject:time forKey:@"come_date"];
//                    [_infoDic setObject:time forKey:arriveTimeKey];

                    break;
                default:
                    break;
            }
        NSLog(@"date==%@",date);
    }];
    */
}
@end
